package com.liaoban.app.ui.message;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.liaoban.app.R;
import com.liaoban.app.adapter.CallHistoryAdapter;
import com.liaoban.app.api.type.CallHistory;
import com.liaoban.app.biz.CommonBiz;
import com.liaoban.app.ui.anchor.AnchorDetailActivity;
import com.liaoban.app.ui.base.BaseListActivity;
import com.liaoban.app.ui.login.LoginActivity;
import com.liaoban.app.ui.rank.SearchActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 通话记录
 */
public class CallHistoryActivity extends BaseListActivity<CallHistory> {
    @BindView(R.id.iv_right)
    public ImageView ivRight;

    @Override
    public String getNewTitle() {
        return "通话记录";
    }

    @Override
    public BaseQuickAdapter getAdapter() {
        return new CallHistoryAdapter(null);
    }

    @Override
    public void itemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {

    }

    @Override
    public void itemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
        if (!CommonBiz.getInstance().isLogin(this)) {
            startActivity(new Intent(this, LoginActivity.class));
            return;
        }
        CallHistory callHistory = (CallHistory) baseQuickAdapter.getData().get(position);
        startActivity(AnchorDetailActivity.newIntent(this, callHistory.getWuserId() + ""));
    }

    @Override
    public void getData() {
        startTask(CommonBiz.getInstance().callList(), listBaseResponse -> {
            doSuc(listBaseResponse.data, listBaseResponse.totalPageCount);
        });
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        ivRight.setImageResource(R.mipmap.ic_search_title);
        ivRight.setVisibility(View.VISIBLE);
    }

    @OnClick(R.id.iv_right)
    public void right() {
        startActivity(new Intent(this, SearchActivity.class));
    }
}
